<%@ page language="java" import="java.util.*,com.shop.mall.dao.impl.*,com.shop.mall.entity.*"
         pageEncoding="utf-8" %>
<%@ page import="com.shop.mall.dao.impl.UserDaoImpl" %>
<%@ page import="com.shop.mall.entity.User" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
</head>
<body>

<%
    request.setCharacterEncoding("utf-8");

    String username = request.getParameter("username");

    String userpwd = request.getParameter("userpwd");

    User userinfo = new User();
    userinfo.setName(username);
    userinfo.setPassword(userpwd);

    UserDaoImpl udao = new UserDaoImpl();
    int r = udao.login(userinfo);
    if (r == 1) {
        out.println("<script>alert('登录成功');location.href='goods.jsp';</script>");
    } else {
        out.println("<script>alert('登录失败');location.href='login.jsp';</script>");
    }

		/*
		if (r == 1) {
			//重定向
			response.sendRedirect("index.jsp");
		} else {
			//重定向
			response.sendRedirect("login.jsp");
		}
		 */
		/*
		if (r == 1) {
			//转发
			request.getRequestDispatcher("index.jsp").forward(request,
					response);
		} else {
			//转发
			request.getRequestDispatcher("login.jsp").forward(request,
					response);
		}*/

		/*

		String[] hobbys = request.getParameterValues("hobby");

		out.print("用户名：" + username);

		out.print("<br/>密码：" + userpwd);

		if (hobbys != null) {
			for (int i = 0; i < hobbys.length; i++) {
				out.print("<br/>爱好：" + hobbys[i]);
			}
		}

		if ("admin".equals(username) && "321".equals(userpwd)) {
			//转发
			request.getRequestDispatcher("index.jsp").forward(request,
					response);

		}*/
%>

</body>
</html>
